package com.fms.data.messaging;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

import org.jmock.Expectations;
import org.jmock.Mockery;

import com.fms.data.messaging.data.EmailDataFileFiller;
import com.fms.model.domain.FlowSheet;
import com.fms.model.messaging.domain.IEmailData;

public class EmailDataFileRepositoryTest extends TestCase
{
	
	private Mockery mock;

	
	public void setUp()
	{
		File f = new File("config/email.cfg");
		if(f.exists())
		{
			f.delete();
		}
		mock = new Mockery();
	}
	
	
	public void tearDown()
	{
		mock.assertIsSatisfied();
	}
	
	public void testEmailDataSave()
	{
		
		EmailDataFileFiller r = new EmailDataFileFiller();
		
		final IEmailData data = mock.mock(IEmailData.class);
		
		final List<String> dests = new ArrayList<String>();
		dests.add("dest one");
		dests.add("dest two");
		dests.add("dest three");
		
		mock.checking(new Expectations()
		{{
			oneOf(data).getSubject(); will(returnValue("Test Subject"));
			oneOf(data).getMessage(); will(returnValue("Test Message"));
			oneOf(data).getFlowSheet(); will(returnValue(new FlowSheet("TEST")));
			atLeast(1).of(data).getDestinations(); will(returnValue(dests));
			
			
			oneOf(data).setSubject(with(equal("Test Subject")));
			oneOf(data).setMessage(with(equal("Test Message")));
			oneOf(data).setFlowSheet(with(any(FlowSheet.class)));
			oneOf(data).addDestination(with(equal("dest one")));
			oneOf(data).addDestination(with(equal("dest two")));
			oneOf(data).addDestination(with(equal("dest three")));
		}});
		
		
		r.save(data);
		
		r.fill(data);
		
		
		
		
		
	}
	
	
	
}
